package com.dong.ui.util;

import com.dong.common.constant.PropertiesConst;
import com.dong.common.util.PropertiesUtils;
import com.dong.ui.constant.IconConst;

import javax.swing.*;
import java.awt.*;
import java.io.IOException;

/**
 * @description: 图标工具类
 * @author: 陈瑞东
 * @create: 2021-08-27 08:54
 */
public class IconUtils {

    /**
     * 获取图标
     * @param iconName
     * @return
     */
    public static ImageIcon getIcon(String dir, String iconName){
//        String dirPath = IconUtils.class.getClassLoader().getResource(dir).getPath() + "/";
        String dirPath = dir + "/";
        ImageIcon imageIcon = new ImageIcon(dirPath + PropertiesUtils.getValue(PropertiesConst.ICON_CONFIG_NAME, iconName));
        return imageIcon;
    }

    /**
     * 获取标题图标
     * @return
     */
    public static Image getTitleIcon(){
        ImageIcon imageIcon = getIcon(IconConst.ICON_DIR, PropertiesConst.ICON_KEY_FAVICON);
        return imageIcon.getImage();
    }

    /**
     * 获取首页顶部导航栏图标
     * @param iconName
     * @return
     */
    public static ImageIcon getHomeTopIcon(String iconName) {
        return getIcon(IconConst.ICON_DIR, iconName);
    }

    /**
     * 获取状态图标
     * @param iconName
     * @return
     */
    public static ImageIcon getStatusIcon(String iconName) {
        return getIcon(IconConst.ICON_DIR, iconName);
    }

    /**
     * 获取功能性图标
     * @param iconName
     * @return
     */
    public static ImageIcon getFnIcon(String iconName) {
        return getIcon(IconConst.ICON_DIR, iconName);
    }
}
